package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.dto.NursingPlanDto;
import com.zzyl.entity.NursingPlan;
import com.zzyl.entity.NursingProjectPlan;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectPlanVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * ClassName:NursingPlanMapper
 * package:com.zzyl.mapper
 * description:
 *
 * @author 刘
 * @version 1.0
 * @Create 2024/5/31 14:48
 */
@Mapper
public interface NursingPlanMapper {

    //查询全部护理计划
    @Select("select * from nursing_plan")
    List<NursingPlanVo> selectAllPlan();


    //新增护理计划（除护理项目外的数据）
    void insertNursingPlan(NursingPlan nursingPlan);
    //新增护理计划中的护理项目集合
    void insertNursingProjectPlan(List<NursingProjectPlan> projectPlans);

    //条件分页查询
    Page<NursingPlanVo> selectByLimit(String name, Integer status);



    //根据id查询，先查nursingProjectPlan表数据projectPlans集合
    List<NursingProjectPlanVo> selectProjectPlans(Integer id);
    //再查询nursingPlan表数据
    NursingPlanVo selectPlanById(Integer id);


    //编辑修改，先修改NursingPlanDto除projectPlans的内容
    void updateById(NursingPlan nursingPlan);
    //先删除所有此计划下的项目（然后在此计划下新增项目，调用上面的insertNursingProjectPlan）
    @Delete("delete from nursing_project_plan where plan_id = #{id}")
    void deleteProjectPlan(Integer id);


    //删除，1、删除计划表中数据。2、删除中间表中数据（调用上面的deleteProjectPlan）
    @Delete("delete from nursing_plan where id = #{id}")
    void deletePlan(Integer id);

    //启用禁用
    @Update("update nursing_plan set status = #{status} where id = #{id}")
    void updateStatusById(Integer id, Integer status);

//    void insertNursingProjectPlan(List<NursingProjectPlan> projectPlans);
}
